const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    entry: {
        main: './src/main.ts',
        "pdf.worker": "./node_modules/pdfjs-dist/build/pdf.worker.entry.js",
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/,
            },
            {
                test: /pdf\.worker\.js$/,
                use: 'file-loader'
            }
        ],
    },
    resolve: {
        extensions: ['.tsx', '.ts', '.js'],
    },
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist'),
        // library: {
        //     name: 'WebpackPdf',
        //     type: 'umd',
        // },
        clean: true,
    },
    plugins: [
        new CopyWebpackPlugin({
            patterns: [
                { from: 'src/index.html', to: '' },
                { from: 'pdfs/helloworld.pdf', to: '' },
                // 可以添加更多的文件复制配置
            ],
        }),
    ],
};
